package com.dfbz.设计模式.factory;

/*
水果工厂
 */
public class FruitFactory {

    /**
     * 创建水果方法
     * @param fruitName
     * @return
     */
    public Fruit createFruit(String fruitName) {

        if ("apple".equals(fruitName)) {
            return new Apple();
        } else if ("pear".equals(fruitName)) {

            return new Pear();
        }

        return null;
    }

}
